/*
 * TypeParameterNode.cpp
 *
 *  Created on: 29/nov/2010
 *      Author: computer
 */

#include "DerivationTree.h"
#include "FunctionDefinitionInstruction.h"
#include "Pattern.h"
#include "TemplatePattern.cpp"

TypeParameterNode::TypeParameterNode() : NodeTree_CRTP<TypeParameterNode>(), buffer(0), length(0) { }

TypeParameterNode::TypeParameterNode(char* _buffer, unsigned int _length) : NodeTree_CRTP<TypeParameterNode>(), buffer(_buffer), length(_length) { }

TypeParameterNode::TypeParameterNode(const TypeParameterNode& copy) : NodeTree_CRTP<TypeParameterNode>(copy) {
	length = copy.length;//TODO memory leak
	buffer = new char[length];
	for (unsigned int i = 0; i < length; ++i) buffer[i] = copy.buffer[i];
}

std::string TypeParameterNode::getName() const {
	return std::string(buffer);
}

bool TypeParameterNode::execute(Pointer<LeonardVirtualMachine> LVM) {
	PatternRecognition::TypePattern pattern(this->getName(), "");//TODO no name
	LVM->pushPattern(PatternRecognition::Pattern<>(pattern));
	return true;
}

